package logic

import (
	"context"
	"login-api/loginrpc/internal/svc"
	"login-api/loginrpc/loginrpc"
	"login-api/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProductAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewProductAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProductAddLogic {
	return &ProductAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品添加
func (l *ProductAddLogic) ProductAdd(in *loginrpc.ProductAddRequest) (*loginrpc.ProductAddResponse, error) {
	// todo: add your logic here and delete this line

	var product models.Product
	if err := product.ProductAdd(models.DB); err != nil {
		return nil, err
	}

	return &loginrpc.ProductAddResponse{
		ProductId: int64(product.ID),
	}, nil
}
